package com.sofaguest.controller;

import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.sofaguest.entry.SofaResult;
import com.sofaguest.service.SofaService;

@Controller
@RequestMapping("/sofa")
public class SofaController {

    @Resource
    private SofaService sofa;

    @ResponseBody
    @RequestMapping("/qrySimpleSofa.do")
    public SofaResult qrySimpleSofa(String address, String sex, int minAge, int maxAge, int pernum) {
        return sofa.qrySimpleSofa(address, sex, minAge, maxAge, pernum);
    }

    @ResponseBody
    @RequestMapping("/qrySofaByHostId.do")
    public SofaResult qrySofaByHostId(String hostId) {
        return sofa.qrySofaByHostId(hostId);
    }

    @ResponseBody
    @RequestMapping("/qrySofa.do")
    public SofaResult qrySimpleSofa(String sofaId) {
        return sofa.qrySofa(sofaId);
    }

    @ResponseBody
    @RequestMapping("/addSofaEmg.do")
    public SofaResult addSofaEmg(@RequestParam("sofapic") MultipartFile sofapic, HttpServletRequest request,
            HttpServletResponse response) throws IOException {
        return sofa.addSofaEmg(sofapic, request, response);
    }

    @ResponseBody
    @RequestMapping("/addSofa.do")
    public SofaResult addSofa(String sofaId, String hostId, String sofaname, String sofaAddress, String sofaType,
            String maxper, String sexlim, String agelim, String linkTel, String mail, String mixday, String baseres,
            String explain) {
        return sofa.addSofa(sofaId, hostId, sofaname, sofaAddress, sofaType, maxper, sexlim, agelim, linkTel, mail,
                mixday, baseres, explain);
    }

    @ResponseBody
    @RequestMapping("/qrySofaList.do")
    public SofaResult qrySofaList() {
        return sofa.qrySofaList();
    }

    @ResponseBody
    @RequestMapping("/getSofaList.do")
    public SofaResult getSofaList(int byTimeTag) {
        return sofa.getSofaList(byTimeTag);
    }
}
